 log using session_output


clear all
use data.dta 


*********************************************************************************************
*                     Table 1
*********************************************************************************************

* % Social democratic Parties

*Voters (first row)

tabstat PS, s(mean)  format(%5.0g)
*Abstainers (CEM) (second row) // three entries for three columns (basic, augmented, full)
tabstat PScem_basic PScem_augmented PScem_full, s(mean)  format(%5.0g)
*Abstainers (logit) (third row)
tabstat PSlogit_basic PSlogit_augmented PSlogit_full, s(mean) format(%5.0g)
*Abstainers (logit+) (fouth row)
tabstat PSlogitplus_basic PSlogitplus_augmented PSlogitplus_full, s(mean) format(%5.0g)


* % Extreme left Parties

*Voters (first row)
tabstat left, s(mean)  format(%5.0g)

*Abstainers (CEM) (second row)  
tabstat leftcem_basic leftcem_augmented  leftcem_full, s(mean)  format(%5.0g)
*Abstainers (logit) (third row)
tabstat leftlogit_basic leftlogit_augmented leftlogit_full, s(mean)  format(%5.0g)
*Abstainers (logit+) (fouth row)
tabstat leftlogitplus_basic leftlogitplus_augmented leftlogitplus_full, s(mean)  format(%5.0g)


* % Green Parties

*Voters (first row)

tabstat green, s(mean)  format(%5.0g)

*Abstainers (CEM) (second row)  
tabstat greencem_basic  greencem_augmented greencem_full , s(mean)  format(%5.0g)
*Abstainers (logit) (third row)
tabstat greenlogit_basic  greenlogit_augmented greenlogit_full, s(mean)  format(%5.0g)
*Abstainers (logit+) (fouth row)
tabstat greenlogitplus_basic greenlogitplus_augmented greenlogitplus_full, s(mean)  format(%5.0g)


*%Turnout

*Sample turnout
tabstat voting, s(mean)  format(%5.0g)
*Compulsory (CEM)
tabstat turnout_basic turnout_augmented turnout_full, s(mean) format(%5.0g)
*Compulsory (logit)
tabstat turnout_logit turnout_logit turnout_logit, s(mean) format(%5.0g)   
*Compulsory (logit +)
tabstat turnout_basic turnout_augmented turnout_full, s(mean) format(%5.0g)



*****************************************************************************************************************
*                                Figure 1 
*****************************************************************************************************************


quietly summarize education
local mean: display %6.2f r(mean)
local edusd: display %6.2f r(sd)
local edumin: display %6.2f r(min)
local edumax: display %6.2f r(max)
quietly summarize education if cem_basic==1
local edu2mean : display %6.2f r(mean)
local edu2sd: display %6.2f r(sd)
local edu2min: display %6.2f r(min)
local edu2max: display %6.2f r(max)
quietly summarize education if cem_augmented==1
local edu3mean : display %6.2f r(mean)
local edu3sd: display %6.2f r(sd)
local edu3min: display %6.2f r(min)
local edu3max: display %6.2f r(max)
quietly summarize education if cem_full==1
local edu4mean : display %6.2f r(mean)
local edu4sd: display %6.2f r(sd)
local edu4min: display %6.2f r(min)
local edu4max: display %6.2f r(max)
twoway  (function y=normalden(x, `edu4mean', `edu4sd') , range(`edu4min' `edu4max')  lwidth(medthick) lcolor(black)  lpattern(dot) ) (function y=normalden(x, `edu3mean', `edu3sd') , range(`edu3min' `edu3max') lwidth(medthick) lcolor(black) lpattern(shortdash)) (function y=normalden(x, `edu2mean', `edu2sd') , range(`edu2min' `edu2max') lcolor(black)  lwidth(medthick) lpattern(longdash)) (function y=normalden(x, `mean', `edusd') , range(`edumin' `edumax')  lwidth(medthick) lcolor(black) ) ,  xtitle("") xlabel(0(1)4, labsize(small)) legend(off) ytitle("") ylabel(0(.1).3, angle(horizontal) labsize(vsmall) format(%3.2f))
graph export a1.png, replace

quietly summarize y
local ymean: display %6.2f r(mean)
local ysd: display %6.2f r(sd)
local ymin: display %6.2f r(min)
local ymax: display %6.2f r(max)
quietly summarize y if cem_basic==1
local y2mean : display %6.2f r(mean)
local y2sd: display %6.2f r(sd)
local y2min: display %6.2f r(min)
local y2max: display %6.2f r(max)
quietly summarize y if cem_augmented==1
local y3mean : display %6.2f r(mean)
local y3sd: display %6.2f r(sd)
local y3min: display %6.2f r(min)
local y3max: display %6.2f r(max)
quietly summarize y if cem_full==1
local y4mean : display %6.2f r(mean)
local y4sd: display %6.2f r(sd)
local y4min: display %6.2f r(min)
local y4max: display %6.2f r(max)
twoway  (function y=normalden(x, `y4mean', `y4sd') , range(`y4min' `y4max') lwidth(medthick) lcolor(black)  lpattern(dot)) (function y=normalden(x, `y3mean', `y3sd') , range(`y3min' `y3max')  lwidth(medthick) lcolor(black) lpattern(shortdash)) (function y=normalden(x, `y2mean', `y2sd') , range(`y2min' `y2max')  lwidth(medthick) lcolor(black) lpattern(longdash)) (function y=normalden(x, `ymean', `ysd') , range(`ymin' `ymax')  lwidth(medthick) lcolor(black) ) , xtitle("") xlabel(1(1)4, labsize(small)) legend(off) ytitle("") ylabel(0(.2).6, angle(horizontal) labsize(vsmall) format(%3.2f))
graph export a2.png, replace

*********************************************************************************************
*                     Table A1
*********************************************************************************************

 
 *for "1st election"   (columns 1 to 4)
 
*columns: "Year"  "N. obs"  "Real"  "Sample"
tabstat      e_year   Nobs      real     voting   if election_dummy==1, s(mean)  format(%10.3g) by(country) nototal
 *for "2nd election"   (columns 5 to 8)
tabstat      e_year   Nobs      real      voting  if election_dummy==2, s(mean)  format(%10.3g) by(country) nototal

*********************************************************************************************
*                    Table A2
*********************************************************************************************

eststo voters: quietly estpost summarize ///
    education agea  female bebe   minority  y uemp3m  wage pension self others  polintr if voting==1
eststo abstainers: quietly estpost summarize ///
    education agea  female bebe   minority  y uemp3m  wage pension self others   polintr if voting==0
	esttab  voters abstainers, ///
	cells("count mean(fmt ( %9.2f))  sd(fmt ( %9.2f))")  nodepvar  ///
label

********************************************************************************************* 
*                     Table A4
*********************************************************************************************


*SOCIAL DEMOCRATIC PARTIES

*Basic
quietly: ttest PS, by(cem_basic) welch
 display as text "Matched-Unmatched (basic)= " as result   r(mu_2) - r(mu_1)    
 display as text "Standard error= " as result   r(se)   
*Augmented 
quietly: ttest PS, by(cem_augmented) welch
 display as text "Matched-Unmatched (augmented)= " as result   r(mu_2) - r(mu_1)    
 display as text "Standard error= " as result   r(se)   
 *Full
quietly: ttest PS, by(cem_full) welch
 display as text "Matched-Unmatched (full)= " as result   r(mu_2) - r(mu_1)    
 display as text "Standard error= " as result   r(se)  

 
*EXTREME LEFT PARTIES

*Basic
quietly: ttest left, by(cem_basic) welch
 display as text "Matched-Unmatched (basic)= " as result   r(mu_2) - r(mu_1)    
 display as text "Standard error= " as result   r(se)   
*Augmented 
quietly: ttest left, by(cem_augmented) welch
 display as text "Matched-Unmatched (augmented)= " as result   r(mu_2) - r(mu_1)    
 display as text "Standard error= " as result   r(se)   
 *Full
quietly: ttest left, by(cem_full) welch
 display as text "Matched-Unmatched (full)= " as result   r(mu_2) - r(mu_1)    
 display as text "Standard error= " as result   r(se)  

 
*GREEN PARTIES

*Basic
quietly: ttest green, by(cem_basic) welch
 display as text "Matched-Unmatched (basic)= " as result   r(mu_2) - r(mu_1)    
 display as text "Standard error= " as result   r(se)   
*Augmented 
quietly: ttest green, by(cem_augmented) welch
 display as text "Matched-Unmatched (augmented)= " as result   r(mu_2) - r(mu_1)    
 display as text "Standard error= " as result   r(se)   
 *Full
quietly: ttest green, by(cem_full) welch
 display as text "Matched-Unmatched (full)= " as result   r(mu_2) - r(mu_1)    
 display as text "Standard error= " as result   r(se)  

******************************************************************************
*                                     Figure A5
******************************************************************************


hist PSmean1 if id_strat_basic==1, fraction  ytitle("") ylabel(0(.1).6, angle(horizontal) labsize(vsmall) format(%3.2f))  xtitle("Basic specification")
graph export g1.png, replace

hist PSmean2 if id_strat_augmented==1, fraction ytitle("")  ylabel(0(.1).6, angle(horizontal) labsize(vsmall) format(%3.2f))   xtitle("Augmented specification")
graph export g2.png, replace

hist PSmean3 if id_strat_full==1, fraction  ytitle("")   ylabel(0(.1).6, angle(horizontal) labsize(vsmall) format(%3.2f))   xtitle("Full specification")
graph export g3.png, replace



*********************************************************************************************
*                             Table A6
*********************************************************************************************


*Test group complete random 
tabstat      real_PSa CEM_PSa      logit_PSa     logitplus_PSa  quadratic_PSa,  format(%10.3g)   
tabstat      real_lefta  CEM_lefta      logit_lefta      logitplus_lefta quadratic_lefta ,  format(%10.2g)   
tabstat      real_greena   CEM_greena      logit_greena    logitplus_greena  quadratic_greena,  format(%10.2g)   

*Test group random within low SES
tabstat      real_PS   CEM_PS      logit_PS     logitplus_PS  quadratic_PS,  format(%10.3g)   
tabstat      real_leftb  CEM_left      logit_left      logitplus_left  quadratic_left ,  format(%10.2g)   
tabstat      real_greenb   CEM_green      logit_green    logitplus_green  quadratic_green,  format(%10.2g)   

*********************************************************************************************
*                                Table A7
*********************************************************************************************

* % Social democratic Parties

*Voters (first row)

tabstat PS, s(mean)  format(%5.0g)
*Abstainers (CEM) (second row) // three entries for three columns (basic, augmented, full)
tabstat PScem_social PScem_trust PScem_ideology, s(mean)  format(%5.0g)
*Abstainers (logit) (third row)
tabstat PSlogit_social PSlogit_trust PSlogit_ideology, s(mean)  format(%5.0g)


* % Extreme left Parties

*Voters (first row)
tabstat left, s(mean)  format(%5.0g)

*Abstainers (CEM) (second row) // three entries for three columns (basic, augmented, full)
tabstat leftcem_social leftcem_trust leftcem_ideology, s(mean)  format(%5.0g)
*Abstainers (logit) (third row)
tabstat leftlogit_social leftlogit_trust leftlogit_ideology, s(mean)  format(%5.0g)


*Green Parties

*Voters (first row)

tabstat green, s(mean)  format(%5.0g)

*Abstainers (CEM) (second row) // three entries for three columns (basic, augmented, full)
tabstat greencem_social greencem_trust greencem_ideology, s(mean)  format(%5.0g)
*Abstainers (logit) (third row)
tabstat greenlogit_social greenlogit_trust greenlogit_ideology, s(mean)  format(%5.0g)


*%Turnout

*Sample turnout
tabstat voting, s(mean)  format(%5.0g)
*Compulsory (CEM)
tabstat turnout_social turnout_trust turnout_ideology, s(mean) format(%5.0g)
*Compulsory (logit)
tabstat turnout_logit turnout_logit turnout_logit, s(mean) format(%5.0g)

*********************************************************************************************
*                              Table A8
*********************************************************************************************



*****Social democratic parties
tabstat    PS ,  format(%10.3g)   
tabstat    PSkernel_basic  PSkernel_augmented PSkernel_full,  format(%10.3g) 
tabstat    PSkernel_reg_basic  PSkernel_reg_augmented PSkernel_reg_full,  format(%10.3g)   
  
*****Extreme left parties 
tabstat    left ,  format(%10.2g)   
tabstat    leftkernel_basic  leftkernel_augmented leftkernel_full,  format(%10.2g) 
tabstat    leftkernel_reg_basic  leftkernel_reg_augmented leftkernel_reg_full,  format(%10.2g)   

*****Green parties
tabstat    green ,  format(%10.2g)   
tabstat    greenkernel_basic  greenkernel_augmented greenkernel_full,  format(%10.2g) 
tabstat    greenkernel_reg_basic  greenkernel_reg_augmented greenkernel_reg_full,  format(%10.2g)   


*********************************************************************************************
*                            Table A9
*********************************************************************************************

                           *Left parties                                                  |                           Incumbent parties
						   
*               "Year"  "Real"         "Matching           "Logit"               |     "Real"                "Matching              "Logit"       
tabstat     e_year   real_left    all_leftcem_full all_leftlogit_full      real_incumbent   incumbentcem_full  incumbentlogit_full  if election_dummy==1, s(mean)  format(%10.3g) by(country) nototal  labelwidth(16)
 *for "2nd election"   (columns 5 to 8)
 *               "Year"  "Real"         "Matching           "Logit"              |     "Real"                "Matching              "Logit"       
tabstat     e_year   real_left    all_leftcem_full all_leftlogit_full      real_incumbent   incumbentcem_full  incumbentlogit_full  if election_dummy==2, s(mean)  format(%10.3g) by(country) nototal

log close
